package com.cn.wanxi.service.impl;

import com.cn.wanxi.entity.NewsEntity;
import com.cn.wanxi.mapper.NewsMapper;
import com.cn.wanxi.service.INewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NewsServiceImpl implements INewsService {

    @Autowired
    private NewsMapper newsMapper;


    @Override
    public List<NewsEntity> findAll(NewsEntity newsEntity) {

        return newsMapper.findAll(newsEntity);
    }

    @Override
    public int getCount(NewsEntity newsEntity) {

        return newsMapper.getCount(newsEntity);
    }

    @Override
    public int del(Integer id) {

        return newsMapper.del(id);
    }

    @Override
    public NewsEntity findById(Integer id) {

        return newsMapper.findById(id);
    }

    @Override
    public String edit(NewsEntity newsEntity) {

        return newsMapper.edit(newsEntity) == 1 ? "success" : "error";
    }

    @Override
    public String add(NewsEntity newsEntity) {

        return newsMapper.add(newsEntity) == 1 ? "success" : "error";
    }
}
